package com.yet.proxy;

import java.lang.reflect.Method;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.InvocationHandler;

public class CglibProxy implements YetProxy {

	@Override
	public Object proxy(Class<?> clz, java.lang.reflect.InvocationHandler invocationHandler) {
		Enhancer enhancer = new Enhancer();
		enhancer.setSuperclass(clz);
		enhancer.setCallback(new InvocationHandler() {
			@Override
			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
				return invocationHandler.invoke(proxy, method, args);
			}
		});
		return enhancer.create();
	}

}
